<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!Doctype html>
<html>
<head>
<meta charset="utf-8">
<title>校园二手市场交易</title>
	<%@include file="/common/header.jsp" %>
</head>
<body>
<form class="layui-form" action="/user/register" method="POST">
	<div class="layui-form-item">
		<label class="layui-form-label">手机号</label>
		<div class="layui-input-inline">
			<input type="text" name="phone" required lay-verify="required|phone|number" placeholder="请输入手机号" autocomplete="off" class="layui-input">
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">用户名</label>
		<div class="layui-input-inline">
			<input type="text" name="userName" required lay-verify="required|username" placeholder="请输入用户名" autocomplete="off" class="layui-input">
		</div>
		<div class="layui-form-mid layui-word-aux">2~12个字符，可使用字母、数字、中文，不能全为数字</div>
	</div>
	
	<div class="layui-form-item">
		<label class="layui-form-label">密码</label>
		<div class="layui-input-inline">
			<input type="password" name="password" required lay-verify="required|pass" placeholder="请输入密码" autocomplete="off" class="layui-input">
		</div>
		<div class="layui-form-mid layui-word-aux">6~12个字符，可使用字母、数字，区分大小写</div>
	</div>
	
	<div class="layui-form-item">
		<label class="layui-form-label">确认密码</label>
		<div class="layui-input-inline">
			<input type="password" required lay-verify="required|repass" placeholder="请确认密码" autocomplete="off" class="layui-input">
		</div>
	</div>
	
	<div class="layui-form-item">
		<label class="layui-form-label">性别</label>
		<div class="layui-input-block">
			<input type="radio" name="sex" value="男" title="男">
			<input type="radio" name="sex" value="女" title="女">
		</div>
	</div>
	
	<div class="layui-form-item">
		<label class="layui-form-label">年龄</label>
		<div class="layui-input-inline">
			<input type="text" name="age" placeholder="请输入年龄" autocomplete="off" class="layui-input">
		</div>
		<div class="layui-form-mid layui-word-aux">此项不是必填项</div>
	</div>
	
	<div class="layui-form-item">
		<label class="layui-form-label">专业</label>
		<div class="layui-input-inline">
			<input type="text" name="major" placeholder="请输入专业" autocomplete="off" class="layui-input">
		</div>
		<div class="layui-form-mid layui-word-aux">此项不是必填项</div>
	</div>
	
	<div class="layui-form-item">
		<label class="layui-form-label">邮箱</label>
		<div class="layui-input-inline">
			<input type="text" name="email" placeholder="请输入常用邮箱" autocomplete="off" class="layui-input">
		</div>
		<div class="layui-form-mid layui-word-aux">此项不是必填项</div>
	</div>
	
	<div class="layui-form-item">
		<label class="layui-form-label">宿舍区</label>
		<div class="layui-input-inline">
			<select name="dormitory">
				<option value=" ">请选择所在宿舍区</option>
				<option value="泰山区">泰山区</option>
				<option value="华山区">华山区</option>
				<option value="启林区">启林区</option>
				<option value="六一区">六一区</option>
				<option value="嵩山区">嵩山区</option>
			</select>
		</div>
		<div class="layui-form-mid layui-word-aux">此项不是必填项</div>
	</div>
	
	<div class="layui-form-item">
		<div class="layui-input-block">
			<button class="layui-btn" lay-submit lay-filter="*">立即注册</button>
		</div>
	</div>

</form>

<script>
layui.use(['jquery','layer','form'], function(){
	var form = layui.form
	var $=layui.$
	,layer=layui.layer;
	
  //自定义验证
  form.verify({
	username:function(value){
		if(!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)){
		return '用户名不能有特殊字符';
    }
		if(/(^\_)|(\__)|(\_+$)/.test(value)){
		return '用户名首尾不能出现下划线\'_\'';
    }
		if(/^\d+\d+\d$/.test(value)){
		return '用户名不能全为数字';
    }
	}
	
	,pass:[/(.+){6,12}$/, '密码必须6到12位']
	,repass:function(value){
		var repassvalue=$("input[name='password']").val();
		if(value!=repassvalue){
			return '两次输入的密码不一致'
		}
	}
  });
  
  form.on('submit(*)',function(){
	//window.location.href="login.jsp"
	//return false;
  });
  
  form.render();
});

</script>      